import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import static java.util.Collections.swap;

/**s
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-09-27
 * Time: 0:21
 */
public class Code {

    String suit;
    int number;
    public static final String[] suits={"❤","♠","♦","♣"};

    @Override
    public String toString() {
        return "Code{" +
                suit +
                 number +
                '}';
    }

    public Code() {

    }

    public Code(String suit, int number) {
        this.suit=suit;
        this.number=number;
    }


    public static List<Code> buycode(){
        //初始化牌面
        List<Code> codeList=new ArrayList<>();
        for (int i = 0; i < 13; i++) {
            for (int j = 0; j < 4; j++) {
                String suit=suits[j];
                int number=i;
                Code code=new Code(suit,number);
                codeList.add(code);

            }
        }
        return codeList;
    }
    public static List<Code> randcode(List<Code> codeList){
        //洗牌
        Random random=new Random();
        for (int i = codeList.size()-1; i>0; i--) {
            int a=random.nextInt(i);
            swap(codeList,i,a);
        }
        return codeList;
    }

    public static List<List<Code>> play(List<Code> codeList){
        List<Code> h1=new ArrayList<>();
        List<Code> h2=new ArrayList<>();
        List<Code> h3=new ArrayList<>();

        List<List<Code>> h=new ArrayList<>();
        h.add(h1);
        h.add(h2);
        h.add(h3);

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 5; j++) {
                Code code=codeList.remove(0);
                h.get(i).add(code);
            }
        }
        return h;
    }

}
